﻿//
(function() {

// insert your plugin name here
// eg : var mypluginname = 'darkpoulpo-button';

var mypluginname = 'darkpoulpo-button'; // change it

$(window).data('gui').plugins[mypluginname] =
{

  // makeHTML is called to create the html elements
  // options are in your ui.xml
  makeHTML : function(params)
  {
    /*
    params.options['titlebar-fixe'];
	
	
	params.parent
	
	params.xml
    */

	
    var obj = document.createElement("div"); // don't erase
    // obj.setAttribute('data-type', mypluginname);  // deprecied, uncomment if u make a window plugin
	param.parent.appendChild(obj); //add
	
	obj.setAttribute('data-effect','legend');  // see the wiki (makeyourplugin)
	
	/*
	 uncomment if you have any childrens
	
		guiTareNameSpace.executeChildrensPlugin(param.xml,obj);
		see the inline, vertical, groupbox plugins
	*/

	/*  edit your code here

		var txt = params.xml.getAttribute('text');
		obj.setAttribute('data-effect','');
		if (txt) $(obj).text(txt);
	*/


    return  obj; // don't erase
		// return null if error
  },

	 // this api can make a button element in your ui.xml
  // for the future gui creator
  // return a element or null if error
  makeXML : function(xml)
  {
		var element = xml.ownerDocument.createElement(mypluginname); // don't erase

		/* edit your code here

		element.setAttribute('text',this.jquery.text());


		*/

		return element; // don't erase
		// return null if error
  },
	enable : function(flag)
  {
	if (flag !== undefined && flag !== null)
	{
		if (flag == true || flag == false) this[0].disabled = flag;
		return this;
	} else {
		return (this[0].disabled == false);
	}
  },
  
  readonly : function(flag)
  {
	if (flag !== undefined && flag !== null)
	{	
		if (flag == true || flag == false) this[0].readOnly = flag;
		return this;
	} else {
		return this[0].readOnly;
	}
  },
  
  value : function(val)
  {
	if (val !== undefined && val !== null)
	{
		this[0].value = val;
		return this;
	} else {
		return this[0].value;
	}
  },
   
  autofocus : function(flag)
  {
	if (flag !== undefined && flag !== null)
	{
		if (flag == true || flag == false) this[0].autofocus = flag;
		return this;
	} else {
		return this[0].autofocus;
	}
  },
  
  check : function(flag)
  {
	if (flag !== undefined && flag !== null)
	{
		if (flag == true || flag == false) this[0].checked = flag;
		return this;
	} else {
		return this[0].checked;
	}
  },
  
	api1 : function()
	{},
	api2 : function()
	{}

  }
})();